import 'dart:io';
import 'package:dio/dio.dart';
import 'package:flutter_application_cyber/model/cn_net_response.dart';
import 'package:flutter_application_cyber/model/cn_user_default_cache.dart';
import 'package:flutter_application_cyber/net/cn_net_api.dart';
import 'package:flutter_application_cyber/model/cn_object_cache.dart';
import 'package:flutter_application_cyber/tools/cn_uuid_utils.dart';
import 'package:rongcloud_im_wrapper_plugin/rongcloud_im_wrapper_plugin.dart';
import 'package:flutter_application_cyber/tools/cn_common_global.dart';
import '../model/cn_ossPolic_model.dart';
import '../tools/cn_event_bus.dart';
import '../tools/cn_constant_pool.dart';
import '../tools/cn_app_utils.dart';
import '../tools/cn_device_utils.dart';
import 'cn_net_service.dart';
import 'package:flutter_application_cyber/pages/Mine/Models/cn_playGoodModel.dart';
import 'package:flutter_application_cyber/pages/Mine/Models/cn_goodItemModel.dart';
import 'package:flutter_application_cyber/pages/Mine/Models/cn_goodsModel.dart';
import 'package:http_parser/http_parser.dart';
import 'package:flutter_application_cyber/model/user_info_datesource.dart';

const kIMTokenKey = "IMTokenKey"; ////融云appkey
const kGetAppConfigVerKey = "getAppConfigVerKey";
const kMicrosoftTranslationKey = "microsoftTranslationKey";
const kRongCloudAppKey = "rongCloudAppKey";
const kAgoraRtcAppKey = "agoraRtcAppKey";


class CnNetHelper {
  static void init(
    String baseUrl,
    int connectTimeout,
    int receiveTimeout,
    Map<String, dynamic> headers,
    List<Interceptor> interceptors,
  ) {
    CnNetService()
        .init(baseUrl, connectTimeout, receiveTimeout, headers, interceptors);
  }

  static void setHeaders(Map<String, dynamic> headers) {
    CnNetService().setHeaders(headers);
  }

  static void cancelRequests({CancelToken? token}) {
    CnNetService().cancelRequests(token: token);
  }

  static Options setAuthorizationHeader(Options requestOptions) {
    return CnNetService().setAuthorizationHeader(requestOptions);
  }

//restful get
  static Future get(
    String path, {
    Map<String, dynamic>? params,
    Options? options,
    CancelToken? cancelToken,
  }) async {
    Options requestOptions = setAuthorizationHeader(options ?? Options());
    requestOptions.contentType = Headers.jsonContentType;
    requestOptions.responseType = ResponseType.json;

    // var appName = CnAppUtils.getAppName();
    var packageName = await CnAppUtils.getPackageName();
    var version = await CnAppUtils.getVersionNumber();
    var deviceID = await CnDeviceUtils.getDeviceId();
    var deviceModel = await CnDeviceUtils.getModel();
    var systemName = await CnDeviceUtils.getSystemName();
    var token = await CnUserDefaultCacheHelper.getAuthToken();
    var build = await CnAppUtils.getVersionName();

    requestOptions.headers = {
      HttpHeaders.acceptHeader: 'application/json',
      HttpHeaders.acceptCharsetHeader: 'charset=UTF-8',
      HttpHeaders.contentTypeHeader: 'application/json;charset=UTF-8',
      CnConstantPool.pkg: packageName,
      //包名
      CnConstantPool.ver: build, //版本号
      CnConstantPool.deviceId: deviceID, //设备id
      CnConstantPool.model: deviceModel, //设备型号
      CnConstantPool.kst: '1', //
      CnConstantPool.sysLan: 'en', //系统语言
      CnConstantPool.lang: 'en', //系统语言
      CnConstantPool.pver: version, // build number
      CnConstantPool.platform: systemName,
      CnConstantPool.authorization: 'Bearer$token'
    };

    requestOptions.method = 'GET';
    print(requestOptions.headers);

    return CnNetService().get(path,
        params: params, options: requestOptions, cancelToken: cancelToken);
  }

  static Future loginPost(String path,
      {required Map<String, dynamic> params,
      Options? options,
      CancelToken? cancelToken,
      String? mainPhone,
      String? authStr}) async {
    Options requestOptions = setAuthorizationHeader(options ?? Options());
    requestOptions.contentType = Headers.jsonContentType;
    requestOptions.responseType = ResponseType.json;

    // var appName = CnAppUtils.getAppName();
    var packageName = await CnAppUtils.getPackageName();
    var version = await CnAppUtils.getVersionNumber();
    var deviceID = await CnDeviceUtils.getDeviceId();
    var deviceModel = await CnDeviceUtils.getModel();
    var systemName = await CnDeviceUtils.getSystemName();
    var token = await CnUserDefaultCacheHelper.getAuthToken();
    var build = await CnAppUtils.getVersionName();

    requestOptions.headers = {
      HttpHeaders.acceptHeader: 'application/json',
      HttpHeaders.acceptCharsetHeader: 'charset=UTF-8',
      HttpHeaders.contentTypeHeader: 'application/json;charset=UTF-8',
      CnConstantPool.pkg: packageName,
      //包名
      CnConstantPool.ver: build, //版本号
      CnConstantPool.deviceId: deviceID, //设备id
      CnConstantPool.model: deviceModel, //设备型号
      CnConstantPool.kst: '1', //
      CnConstantPool.sysLan: 'en', //系统语言
      CnConstantPool.lang: 'en', //系统语言
      CnConstantPool.pver: version, // build number
      CnConstantPool.platform: systemName,
      CnConstantPool.authorization: 'Bearer$token'
    };

    requestOptions.method = 'POST';

    return CnNetService().loginPost(path,
        params: params, options: requestOptions, cancelToken: cancelToken);
  }

//restfult post
  static Future post(String path,
      {dynamic params,
      Map<String, dynamic>? data,
      Options? options,
      CancelToken? cancelToken,
      String? mainPhone,
      String? authStr}) async {
    Options requestOptions = setAuthorizationHeader(options ?? Options());
    requestOptions.contentType = Headers.jsonContentType;
    requestOptions.responseType = ResponseType.json;

    // var appName = CnAppUtils.getAppName();
    var packageName = await CnAppUtils.getPackageName();
    var version = await CnAppUtils.getVersionNumber();
    var build = await CnAppUtils.getVersionName();

    var deviceID = await CnDeviceUtils.getDeviceId();
    var deviceModel = await CnDeviceUtils.getModel();
    var systemName = await CnDeviceUtils.getSystemName();
    var token = await CnUserDefaultCacheHelper.getAuthToken();

    requestOptions.headers = {
      HttpHeaders.acceptHeader: 'application/json',
      HttpHeaders.acceptCharsetHeader: 'charset=UTF-8',
      HttpHeaders.contentTypeHeader: 'application/json;charset=UTF-8',
      CnConstantPool.pkg: packageName,
      //包名
      CnConstantPool.ver: build, //版本号
      CnConstantPool.deviceId: deviceID, //设备id
      CnConstantPool.model: deviceModel, //设备型号
      CnConstantPool.kst: '1', //
      CnConstantPool.sysLan: 'en', //系统语言
      CnConstantPool.lang: 'en', //系统语言
      CnConstantPool.pver: version, // build number
      CnConstantPool.platform: systemName,
      CnConstantPool.authorization: 'Bearer$token'
    };

    requestOptions.method = 'POST';
    print(requestOptions.headers);

    return CnNetService().post(path,
        params: params,
        data: data,
        options: requestOptions,
        cancelToken: cancelToken);
  }

//restful post form表单
  static Future postForm(
    String path, {
    Map<String, dynamic>? params,
    Options? options,
    CancelToken? cancelToken,
  }) async {
    return CnNetService().postForm(path,
        params: params, options: options, cancelToken: cancelToken);
  }

  static Future postImageForm(
    String path, {
    dynamic data,
    Options? options,
    CancelToken? cancelToken,
  }) async {
    Options requestOptions = setAuthorizationHeader(options ?? Options());
    requestOptions.contentType = 'multipart/form-data';
    requestOptions.responseType = ResponseType.plain;

    var appName = CnAppUtils.getAppName();
    var packageName = await CnAppUtils.getPackageName();
    var version = await CnAppUtils.getVersionNumber();
    var build = await CnAppUtils.getVersionName();
    var deviceID = await CnDeviceUtils.getDeviceId();
    var deviceModel = await CnDeviceUtils.getModel();
    var systemName = await CnDeviceUtils.getSystemName();
    var token = await CnUserDefaultCacheHelper.getAuthToken();

    requestOptions.headers = {
      HttpHeaders.acceptHeader: 'application/json',
      HttpHeaders.acceptCharsetHeader: 'charset=UTF-8',
      HttpHeaders.contentTypeHeader: 'multipart/form-data',
      "pkg": packageName,
      //包名
      CnConstantPool.ver: build, //版本号
      CnConstantPool.deviceId: deviceID, //设备id
      CnConstantPool.model: deviceModel, //设备型号
      CnConstantPool.kst: '1', //
      CnConstantPool.sysLan: 'en', //系统语言
      CnConstantPool.lang: 'en', //系统语言
      CnConstantPool.pver: version, // build number
      CnConstantPool.platform: systemName,
      CnConstantPool.authorization: 'Bearer$token'
    };

    requestOptions.method = 'POST';
    print('deviceID:${deviceID}');

    return CnNetService().postUpLoadImage(path,
        data: data, options: requestOptions, cancelToken: cancelToken);
  }

//登录验证  获取鉴权串（快速登录）
  static userLogin(String token, int oauthType, Function callBack) {
    var param = {
      "oauthType": oauthType,
      "token": token
    }; //"9cyber03489C-C356-4028-972B-8D74F2256C9C"
    CnNetHelper.loginPost(CnApiNet.kPath_login, params: param).then((value) {
      HDHResponseData? response = value;
      print(oauthType.toString());
      bool result = false;
      var msg = '';
      if (response != null && response.code == 0 && response.success == true) {
        msg = '成功';
        result = true;
      } else {
        msg = response?.msg ?? '';
      }
      callBack(response, result, msg);
    });
  }

  //校验token
  static postIsValidToken(String token, Function callBack) {
    var param = {"token": token}; //"9cyber03489C-C356-4028-972B-8D74F2256C9C"
    CnNetHelper.post(CnApiNet.kPath_isValidToken, params: param).then((value) {
      HDHResponseData? response = value;

      bool result = false;
      var msg = '';
      if (response != null && response.code == 0 && response.success == true) {
        msg = '成功';
        result = true;
      } else {
        msg = response?.msg ?? '';
      }
      callBack(response, result, msg);
    });
  }

  //获取策略数据
  static strategyGet(Function callBack) {
    CnNetHelper.get(CnApiNet.kPath_getStrategy).then((value) {
      callBack(value);
    });
  }

  //获取策略数据(异步)
  static Future<HDHResponseData?> strategyGetBlock() async {
    return await CnNetHelper.get(CnApiNet.kPath_getStrategy);
  }

  static Future<bool> getAppConfig() async {
    var ver = await CnUserDefaultCacheHelper.getAppConfigVer();
    ver = '0';
    var params = {'ver': '0'};
    HDHResponseData? hData =
        await CnNetHelper.get(CnApiNet.kPath_getAppConfig, params: params);
    if (hData != null && hData.code == 0 && hData.data != "") {
      var configData = ConfigModelData.fromJson(hData.data);
      CnUserDefaultCacheHelper.setUserDefault('ver', configData.ver);
      for (ConfigItemsModel model in configData.items!) {
        if (model.name == "rck") {
          CnUserDefaultCacheHelper.setUserDefault(kRongCloudAppKey, model.data);
          initRongCloudAppKeyWithAppKey(model.data!);
        } else if (model.name == "rtck") {
          CnUserDefaultCacheHelper.setUserDefault(kAgoraRtcAppKey, model.data);
        } 
      }
      return true;
    }

    return ver != '0';
  }

  static initRongCloudAppKeyWithAppKey(String appKey) {
    CnUserDefaultCacheHelper.getUserDefault(kRongCloudAppKey)
        .then((value) async {
      if (value.isNotEmpty) {
        RCIMIWEngineOptions options = RCIMIWEngineOptions.create();
        RCIMIWEngine engine = await RCIMIWEngine.create(appKey, options);

        CnGlobal.engine = engine;
        //获取融云token
        CnNetHelper.get(CnApiNet.kPath_getRongCloudToken, params: {})
            .then((value) {
          if (value != null) {
            HDHResponseData response = value;
            if (response.code == 0) {
              RCIMIWConnectCallback? callback =
                  RCIMIWConnectCallback(onDatabaseOpened: (int? code) {
                engine.onConnectionStatusChanged =
                    (RCIMIWConnectionStatus? status) {
                  if (status != RCIMIWConnectionStatus.connected) {
                    RCIMIWConnectCallback? callback =
                        RCIMIWConnectCallback(onDatabaseOpened: (int? code) {
                      print(code);
                    }, onConnected: (int? code, String? userId) {
                      print(code);
                    });
                  }
                };
              }, onConnected: (int? code, String? userId) {
                CnEventBus.instance!
                    .commit(EventKeys.RongIMClientConnected, Null);
              });
              engine.connect(response.data, 30, callback: callback);
            }
          }
        });
      }
    });
  }

  //退出登录
  static logoutData(Function callBack) {
    CnNetHelper.post(CnApiNet.kPath_logout, params: {}).then((value) {
      HDHResponseData? response = value;
      bool result = false;
      var msg = '';
      if (response != null && response.code == 0 && response.success == true) {
        msg = '成功';
        result = true;
        CnUserDefaultCacheHelper.setUserDefault('token', '');
        CnUserDefaultCacheHelper.setUserDefault('userId', '');
      } else {
        msg = response?.msg ?? '';
      }
      return callBack(response, result, msg);
    });
  }

  //删除账号
  static deleteAccountData(Function backBlock) {
    CnNetHelper.post(CnApiNet.kPath_deleteAccount, params: {}).then((value) {
      HDHResponseData? response = value;
      bool result = false;
      var msg = '';
      if (response != null && response.code == 0 && response.success == true) {
        msg = '成功';
        result = true;
        CnUserDefaultCacheHelper.setUserDefault('token', '');
        CnUserDefaultCacheHelper.setUserDefault('userId', '');
      } else {
        msg = response?.msg ?? '';
      }
      return backBlock(response, result, msg);
    });
  }

//获取用户信息
  static getUserInfo(String userId, Function backBlock) async {
    var param = {'userId': userId};
    CnNetHelper.get(CnApiNet.kPath_getUserInfo, params: param).then(
      (value) {
        HDHResponseData? response = value;
        bool result = false;
        var msg = '';
        if (response != null &&
            response.code == 0 &&
            response.success == true) {
          msg = '成功';
          result = true;
        } else {
          msg = response?.msg ?? '';
        }
        return backBlock(response, result, msg);
      },
    );
  }

   //获取用户信息
  static getTargetUserInfo(String targetId, Function callBack) {
    Map<String, dynamic>? param;
    // var mainphone = '13822200670';
    // var  authcode = '1d9ad274f19875211e5ac960814f2445';
    // var authstr = '1820600260071322072201130o';
    // Map dictionary = {'mainphone':mainphone,'authstr':authstr,'authcode':authcode};

    if (targetId.isNotEmpty) {
      var path = CnApiNet.kPath_getUserInfo + '?userId=' + targetId;
      CnNetHelper.get(path).then((value) {
        HDHResponseData? response = value;

        bool result = false;
        var msg = '';
        if (response != null &&
            response.code == 0 &&
            response.success == true &&
            response.data != null) {
          msg = '成功';
          result = true;

          UserInfoModel userModel = UserInfoModel.fromJson(response.data);
          UserInfo userInfo = UserInfo();
          userInfo.id = userModel.userId;
          userInfo.name = userModel.nickname;
          userInfo.portraitUrl = userModel.avatarUrl;
          UserInfoDataSource.setUserInfo(userInfo);

          callBack(userModel, result, msg);
          
        }
      });
    }
  }

  //免打扰
  static saveUserInfo(params, Function backBlock) {
    CnNetHelper.post(CnApiNet.kPath_saveUserInfo, params: params).then((value) {
      HDHResponseData? response = value;
      bool result = false;
      var msg = '';
      if (response != null && response.code == 0 && response.success == true) {
        msg = '成功';
        result = true;
      } else {
        msg = response?.msg ?? '';
      }
      return backBlock(response, result, msg);
    });
  }

  static Future<CnOssPolicModel?> getOssPolicyData() async {
    HDHResponseData? response = await CnNetHelper.get(CnApiNet.kPath_policy);
    if (response != null && response.code == 0 && response.data != null) {
      return CnOssPolicModel.coverFromJson(response.data);
    } else {
      return null;
    }
  }

  //上传头像
  static postUploadImageToOssWithImage(
      url, params, imagePath, filename, Function backBlock) async {
    FormData formdata = FormData.fromMap(
      {
        'ossaccessKeyId': params['ossaccessKeyId'],
        'policy': params['policy'],
        'signature': params['signature'],
        'callback': params['callback'],
        'key': params['key'],
        "file": await MultipartFile.fromFile(imagePath,
            filename: filename, contentType: MediaType('image', 'jpeg')),
      },
    );

    CnNetHelper.postImageForm(url, data: formdata).then((value) {
      HDHResponseData? response = value;
      bool result = false;
      var msg = '';
      if (response != null && response.code == 0 && response.success == true) {
        msg = '成功';
        result = true;
      } else {
        msg = response?.msg ?? '';
      }
      return backBlock(response, result, msg);
    });
  }

  //更新头像
  static updateAvatar(params, Function backBlock) {
    CnNetHelper.post(CnApiNet.kPath_updateAvatar, params: params).then((value) {
      HDHResponseData? response = value;
      bool result = false;
      var msg = '';
      if (response != null && response.code == 0 && response.success == true) {
        msg = '成功';
        result = true;
      } else {
        msg = response?.msg ?? '';
      }
      return backBlock(response, result, msg);
    });
  }

  //获取商品信息
  static Future getSearchgoods() async {
    var param = {'isIncludeSubscription': false, 'payChannel': 'IAP'};
    return await CnNetHelper.post(CnApiNet.kPath_searchgoods, params: param);
  }

  static void getGoodList(Function(List<CnPlayGoodModel>) callBack) async {
    HDHResponseData? response = await CnNetHelper.getSearchgoods();
    if (null != response &&
        response.success == true &&
        response.code == 0 &&
        response.data != null) {
      var goodsModel = CnGoodsModel.coverFromJson(response.data);
      callBack(goodsModel.data);
    } else {
      getGoodList(callBack);
    }
  }

  //创建订单
  static createRecharge_a(params, Function backBlock) {
    CnNetHelper.post(CnApiNet.kPath_createRecharge_a, params: params)
        .then((value) {
      HDHResponseData? response = value;
      bool result = false;
      var msg = '';
      if (response != null && response.code == 0 && response.success == true) {
        msg = '成功';
        result = true;
      } else {
        msg = response?.msg ?? '';
      }
      return backBlock(response, result, msg);
    });
  }

  //支付成功后验证凭据
  static paymentIpaData(params, Function backBlock) {
    CnNetHelper.post(CnApiNet.kPath_paymentIpa_a, params: params).then((value) {
      HDHResponseData? response = value;
      bool result = false;
      var msg = '';
      if (response != null && response.code == 0 && response.success == true) {
        msg = '成功';
        result = true;
      } else {
        msg = response?.msg ?? '';
      }
      return backBlock(response, result, msg);
    });
  }

  //获取黑名单数据
  static getBlockListData(Function backBlock) async {
    CnNetHelper.post(CnApiNet.kPath_blockList).then((value) {
      HDHResponseData? response = value;
      bool result = false;
      var msg = '';
      if (response != null && response.code == 0 && response.success == true) {
        msg = '成功';
        result = true;
      } else {
        msg = response?.msg ?? '';
      }
      return backBlock(response, result, msg);
    });
  }

  //解除黑名单

  static postRemoveRecord(String userId, Function backBlock) async {
    var param = {
      "blockUserId": userId,
    };

    CnNetHelper.post(CnApiNet.kPath_removeBlock, params: param).then((value) {
      HDHResponseData? response = value;
      bool result = false;
      var msg = '';
      if (response != null && response.code == 0 && response.success == true) {
        msg = '成功';
        result = true;
      } else {
        msg = response?.msg ?? '';
      }
      return backBlock(response, result, msg);
    });
  }

  static reviewModeConsumeData(int outlay, Function callBack) {
    var param = {"outlay": outlay, 'source': 'iap'};
    CnNetHelper.post(CnApiNet.kPath_reviewModeConsume_a, params: param)
        .then((value) {
      HDHResponseData? response = value;
      bool result = false;
      var msg = '';
      if (response != null && response.code == 0 && response.success == true) {
        msg = '成功';
        result = true;
      } else {
        msg = response?.msg ?? '';
      }
      callBack(response, result, msg);
    });
  }

//获取用户金钱
  static Future<int> getUserCoins() async {
    HDHResponseData? hData =
        await CnNetHelper.get(CnApiNet.kPath_getUserCoins, params: {});
    if (hData != null && hData.code == 0 && hData.data != null) {
      // Provider.of<ChangeUserInfoModel>(ObjectCache.getTopContext()!,
      //         listen: false)
      //     .setCoins(hData.data['availableCoins']);
      return hData.data['availableCoins'];
    } else {
      return 0;
    }
  }

  static getContentSearchData(Function backBlock) async {
    CnNetHelper.post(CnApiNet.kContentSearch, params: {'type': 1})
        .then((value) {
      HDHResponseData? response = value;
      bool result = false;
      var msg = '';
      if (response != null && response.code == 0 && response.success == true) {
        msg = '成功';
        result = true;
      } else {
        msg = response?.msg ?? '';
      }
      return backBlock(response, result, msg);
    });
  }

  static getVideoCallMatchDate(Function backBlock) async {
    CnNetHelper.post(CnApiNet.kvideoCallMatchPath, params: {}).then((value) {
      HDHResponseData? response = value;
      bool result = false;
      var msg = '';
      if (response != null && response.code == 0 && response.success == true) {
        msg = '成功';
        result = true;
      } else {
        msg = response?.msg ?? '';
      }
      return backBlock(response, result, msg);
    });
  }

//加入频道
  static Future<HDHResponseData?> join(
      String channelName, String channelUid) async {
    var param = {"channelName": channelName, "channelUid": channelUid};
    return await CnNetHelper.post(CnApiNet.kPath_channeljoin, params: param);
  }

  //挂断
  static hangUpCall(String channelName, Function callBack) async {
    HDHResponseData? hData = await CnNetHelper.hangUp(channelName);
    if (hData != null && hData.code == 0 && hData.data != null) {
      callBack(hData.data);
    } else {
      callBack(false);
    }
  }

  //挂断
  static Future<HDHResponseData?> hangUp(String channelName) async {
    var param = {
      "channelName": channelName,
      "handUpReason": 5,
    };
    return await CnNetHelper.post(CnApiNet.kPath_hangUp, params: param);
  }

  //创建频道
  static Future<HDHResponseData?> creatChannel(
    String toUserId,
  ) async {
    var param = {
      "toUserId": toUserId,
      "clientSessionId": CnUuidUtils.getUuidV4().toString(),
      "callType": 2,
      "callSource": 12,
      "playSupportType": 1,
      "isFree": true,
      "supportVideoSdks": [1]
    };
    return await CnNetHelper.post(CnApiNet.kPath_createChannel, params: param);
  }

  //频道创建
  static channelGet(String toUserId, Function callBack) async {
    HDHResponseData? response = await CnNetHelper.creatChannel(toUserId);
    bool result = false;
    var msg = '';
    if (response != null && response.code == 0 && response.success == true) {
      msg = '成功';
      result = true;
    } else {
      msg = response?.msg ?? '';
    }
    callBack(response, result, msg);
  }

  //添加关注
  static postAddFriend(String userId) async {
    var param = {
      "followUserId": userId,
    };
    return await CnNetHelper.post(CnApiNet.kPath_AddFriend, params: param);
  }

  //取消关注
  static postUnFriend(String userId) async {
    var param = {
      "followUserId": userId,
    };
    return await CnNetHelper.post(CnApiNet.kPath_unfriend, params: param);
  }

  //屏蔽主播、举报主播
  static postInsertRecord(
      String userId, String? blockingType, String? reasonType) async {
    var param = {
      "broadcasterId": userId,
      "complainCategory": blockingType, //1.屏蔽  2.举报
      "complainSub": reasonType, //举报原因类型
    };
    return await CnNetHelper.post(CnApiNet.kPath_complain, params: param);
  }

  //获取主播墙数据
  static Future<HDHResponseData?> anchorWallGet({required int page}) async {
    var param = {
      "isPageMode": true,
      "isRemoteImageUrl": true,
      "limit": 20,
      "page": page,
      "tag": 'All',
      "category": 'Popular',
    };
    return await CnNetHelper.post(CnApiNet.kPath_searchWall, params: param);
  }

  //分页获取关注列表
  static Future<HDHResponseData?> getFollowPagingList(
      int limit, int page) async {
    var param = {"limit": limit, "page": page};
    return await CnNetHelper.post(CnApiNet.kPath_getFriendList, params: param);
  }

  static logPost(List<Map<String, dynamic>> params, Function callBack) async {
    HDHResponseData? response =
        await CnNetHelper.post(CnApiNet.k_logLiveChatPath, params: params);
    bool result = false;
    var msg = '';
    if (response != null && response.code == 0 && response.success == true) {
      msg = '成功';
      result = true;
    } else {
      msg = response?.msg ?? '';
    }
    callBack(response, result, msg);
  }
}
